package com.nuts.demo.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nuts.base.bean.ResultVO;
import com.nuts.base.core.ResultGenerator;
import com.nuts.base.core.annotation.SameUrlData;
import com.nuts.core.bean.request.LookupReqVO;
import com.nuts.core.tool.service.IEmailService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 测试相关接口
 * 
 * @author 许自辉
 * @date 2017年8月4日
 */
@RestController
@RequestMapping("api/cloud")
// @PermissionPath("系统/用户")
@Api(value = "user-api", tags = { "测试相关接口" })
public class TestController {
	
	@Autowired
	private IEmailService emailService;
//	@Autowired
//	private IEmailRecordService emailRecordService;
	

	@ApiOperation("发送邮件")
	@GetMapping("test/sendEmail")
	public ResultVO sendEmail() throws Exception {
		SimpleMailMessage message = new SimpleMailMessage();
		message.setTo("xuzihui36034@billjc.com");
		Map<String, Object> titleMap = new HashMap<>();
		titleMap.put("username", "xuzihui");
		emailService.sendSimpleMail("test1", titleMap, null, message);
		
//		EmailRecordReqVO reqVO = new EmailRecordReqVO();
//		reqVO.setEmailRecordReqVO(message);
//		emailRecordService.insert(reqVO);
		return  ResultGenerator.getSuccess();
	}
	
	@SameUrlData
	@ApiOperation("测试")
	@PostMapping("test/sendEmail2")
	public ResultVO sendEmail2(LookupReqVO re) throws Exception {
		System.out.println(re.toString());
		return  ResultGenerator.getSuccess();
	}
}
